package com.company.loganalyzer.service;

import java.util.List;
import java.util.Map;

/**
 * LLM服务接口
 * 
 * 提供多种LLM提供商的统一抽象，支持：
 * 1. 意图分析和工具选择
 * 2. 结果综合和格式化  
 * 3. 流式响应支持
 */
public interface LLMService {
    
    /**
     * 分析用户查询意图并选择合适的工具
     * 
     * @param query 用户查询文本
     * @param availableTools 可用工具列表
     * @return 工具选择结果
     */
    ToolSelectionResult analyzeAndSelectTools(String query, List<String> availableTools);
    
    /**
     * 综合多个工具结果，生成用户友好的响应
     * 
     * @param query 原始查询
     * @param toolResults 工具执行结果
     * @return 综合分析结果
     */
    AnalysisResponse synthesizeResponse(String query, Map<String, Object> toolResults);
    
    /**
     * 检查LLM服务是否可用
     * 
     * @return 服务状态
     */
    boolean isAvailable();
    
    /**
     * 工具选择结果
     */
    public static class ToolSelectionResult {
        private final List<String> selectedTools;
        private final Map<String, Object> extractedParameters;
        private final String reasoning;
        
        public ToolSelectionResult(List<String> selectedTools, 
                                 Map<String, Object> extractedParameters,
                                 String reasoning) {
            this.selectedTools = selectedTools;
            this.extractedParameters = extractedParameters;
            this.reasoning = reasoning;
        }
        
        public List<String> getSelectedTools() { return selectedTools; }
        public Map<String, Object> getExtractedParameters() { return extractedParameters; }
        public String getReasoning() { return reasoning; }
    }
    
    /**
     * 分析响应结果
     */
    public static class AnalysisResponse {
        private final String summary;
        private final String analysis;
        private final List<String> recommendations;
        
        public AnalysisResponse(String summary, String analysis, List<String> recommendations) {
            this.summary = summary;
            this.analysis = analysis;
            this.recommendations = recommendations;
        }
        
        public String getSummary() { return summary; }
        public String getAnalysis() { return analysis; }
        public List<String> getRecommendations() { return recommendations; }
    }
}